String.prototype.startsWith() is more idiomatic in that case.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3234>
_iconForNotificationData(icon) {
if (icon) {
- if (icon.substr(0, 7) === 'file://')
+ if (icon.startsWith('file://'))
return new Gio.FileIcon({file: Gio.File.new_for_uri(icon)});
- else if (icon[0] === '/')
+ else if (icon.startsWith('/'))
return new Gio.FileIcon({file: Gio.File.new_for_path(icon)});
else
return new Gio.ThemedIcon({name: icon});